home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDXPRSV.502 / FORWARD < prev    next >
Encoding:
Text File  |  2001-02-09  |  2.5 KB  |  139 lines

  1.  
  2. /* copy the two fats into the new partition */
  3.  
  4. fcpfats(dev, n, stsrc, stdes, buf, siz)
  5.  
  6. int dev;
  7. int n;
  8. long stsrc;
  9. long stdes;
  10. char *buf;
  11. long siz;
  12.  
  13.  
  14. {
  15.  
  16.     int ret, fat2=1;
  17.     long endsrc, tmpstsrc, tmpstdes ;
  18.  
  19.     tmpstdes = stdes + 1;                /* 1 sector is for the boot sect */
  20.     tmpstsrc = stsrc + 1;
  21.     endsrc = tmpstsrc + prvhdr[n].fatsiz; /* 1 sector is for the boot sect */
  22. cpfat:
  23.     while (tmpstsrc != endsrc)    {
  24.         if ((tmpstsrc + siz) > endsrc)
  25.             siz = endsrc - tmpstsrc;
  26.  
  27.         if ((ret = rdsects(dev,(UWORD)siz, buf, tmpstsrc)) != 0)    {
  28.             if (tsterr(ret) == OK)    {
  29.                 return(ERROR);
  30.             }
  31.         }
  32.  
  33.         if ((ret = wrsects(dev,(UWORD)siz, buf, tmpstdes)) != 0)    {
  34.             if (tsterr(ret) == OK)    {
  35.                 return(ERROR);
  36.             }
  37.         }
  38.         tmpstsrc += siz;
  39.         tmpstdes += siz;
  40.     }
  41.     zerosect(dev, tmpstdes, newhdr[n].fatsize - prvhdr[n].fatsiz); 
  42.     if (fat2)    {
  43.         fat2 = 0;
  44.         tmpstsrc = 1 + stsrc + prvhdr[n].fatsiz;
  45.         tmpstdes = 1 + stdes + newhdr[n].fatsize;
  46.         endsrc = tmpstsrc + prvhdr[n].fatsiz; 
  47.         goto cpfat;
  48.     }
  49.     return(OK);
  50. }
  51.  
  52.  
  53.  
  54. /* copy the directory into the new partition */
  55.  
  56. fcpdir(dev, n, stsrc, stdes, buf, siz)
  57.  
  58. int dev;
  59. int n;
  60. long stsrc;
  61. long stdes;
  62. char *buf;
  63. long siz;
  64.  
  65.  
  66. {
  67.  
  68.     int ret;
  69.     long endsrc;
  70.  
  71.     stsrc = 1 + stsrc + 2 * prvhdr[n].fatsiz;/* 1 sector is for the boot sect */
  72.     endsrc = stsrc + prvhdr[n].dirsiz; /* 1 sector is for the boot sect */
  73.     stdes = 1 + stdes + 2 * newhdr[n].fatsize;
  74.  
  75.     while (stsrc != endsrc)    {
  76.         if ((stsrc + siz) > endsrc)
  77.             siz = endsrc - stsrc;
  78.  
  79.         if ((ret = rdsects(dev,(UWORD)siz, buf, stsrc)) != 0)    {
  80.             if (tsterr(ret) == OK)    {
  81.                 return(ERROR);
  82.             }
  83.         }
  84.  
  85.         if ((ret = wrsects(dev,(UWORD)siz, buf, stdes)) != 0)    {
  86.             if (tsterr(ret) == OK)    {
  87.                 return(ERROR);
  88.             }
  89.         }
  90.         stsrc += siz;
  91.         stdes += siz;
  92.     }
  93.     if ((ret = (newhdr[n].dirsize - prvhdr[n].dirsiz)))    { 
  94.         /* directory size is not same */
  95.         zerosect(dev, stdes, ret);
  96.     }
  97.     return(OK);
  98. }
  99.  
  100.  
  101.  
  102. /* do the copy for the header from the previous partition to the new one */
  103.  
  104. fcpsects(dev, stsrc, stdes, endsrc, buf, siz)
  105.  
  106. int dev;
  107. long stsrc;
  108. long stdes;
  109. long endsrc;
  110. char *buf;
  111. long siz;
  112.  
  113.  
  114. {
  115.  
  116.     int ret;
  117.  
  118.     while (stsrc != endsrc)    {
  119.         if ((stsrc + siz) > endsrc)
  120.             siz = endsrc - stsrc;
  121.  
  122.         if ((ret = rdsects(dev,(UWORD)siz, buf, stsrc)) != 0)    {
  123.             if (tsterr(ret) == OK)    {
  124.                 return(ERROR);
  125.             }
  126.         }
  127.  
  128.         if ((ret = wrsects(dev,(UWORD)siz, buf, stdes)) != 0)    {
  129.             if (tsterr(ret) == OK)    {
  130.                 return(ERROR);
  131.             }
  132.         }
  133.         stsrc += siz;
  134.         stdes += siz;
  135.     }
  136.     return(OK);
  137. }
  138.  
  139.